import request from '@/utils/request'

export function addAd(ad) {
  return request({
    url: '/ad/append',
    method: 'post',
    data: {
      adName: ad.adName,
      adType: ad.adType,
      adImg: ad.adImg,
      adLessonId: ad.adLessonId,
      adState: 0
    }
  })
}

export function deleteById(id) {
  return request({
    url: '/ad/remover',
    method: 'get',
    params: {
      id: id
    }
  })
}

export function updateAd(ad) {
  return request({
    url: '/ad/update',
    method: 'get',
    params: {
      adId: ad.adId,
      adName: ad.adName,
      adType: ad.adType,
      adImg: ad.adImg,
      adLessonId: ad.adLessonId,
      adState: ad.adState
    }
  })
}

export function getAllAd() {
  return request({
    url: '/ad/all',
    method: 'get'
  })
}

export function getAdById(id) {
  return request({
    url: '/ad/',
    method: 'get',
    params: {
      id: id
    }
  })
}
